package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.SubjectSortDTO;
import com.CST.service.ys.YsSubjectSortService;
import com.CST.vo.ys.SubjectSortVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cw
 */
@Api(tags = "预算科目排序")
@RestController
@RequestMapping("/ysSubjectSort")
public class YsSubjectSortController {

    @Autowired
    private YsSubjectSortService service;

    @PostMapping("/getSubjectSortList")
    @ApiOperation("获取列表")
    public ResultObject<List<SubjectSortVO>> getSubjectSortList(@RequestParam Integer type){
        List<SubjectSortVO> list = service.getSubjectSortList(type);
        return ResultObject.success(list);
    }

    @PostMapping("/updateSortIndex")
    @ApiOperation("拖动修改排序")
    public ResultObject<String> updateSortIndex(@RequestBody SubjectSortDTO dto){
        return service.updateSortIndex(dto)?ResultObject.success("更新成功"):ResultObject.failed("更新失败");
    }

}
